

import 'package:flutter/material.dart';
import 'package:gczn_hd/app/routes/app_pages.dart';
import 'package:gczn_hd/flavors/build_config.dart';
import 'package:gczn_hd/flavors/env_config.dart';
import 'package:get/get.dart';

class RouteAuthMiddleware extends GetMiddleware{

  // // final MainController mainController = Get.put(MainController());
  // // final LoginController loginController = Get.put(LoginController());
  //
  //
  //   bool loginIn = true;


  @override
  RouteSettings? redirect(String? route) {


    final EnvConfig config = BuildConfig.instance.config;
    if(route != Routes.LOGIN ){
      if( config.token!.isEmpty ){
        return const RouteSettings(name: Routes.LOGIN);
      }
    }


    return super.redirect(route);

  }

  // void isLogin()  async {
  //   final PreferenceManager preferenceManager = Get.find<PreferenceManager>(tag: (PreferenceManager).toString());
  //   String token =  await preferenceManager.getString(PreferenceManager.keyToken) ;
  //   print("isLogin");
  //   loginIn = token.isNotEmpty;
  //
  // }



}